<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
        .list{
            width: 200px;
            height: 150px;
            background-color: skyblue;
            overflow: auto;
        }
        .news{
            height: 30px;
        }
  </style>
</head>

<body>
  <div id="test"></div>

  <script type="text/javascript" src="../js/17.0.1/react.development.js"></script>
  <script type="text/javascript" src="../js/17.0.1/react-dom.development.js"></script>
  <script type="text/javascript" src="../js/17.0.1/babel.min.js"></script>
  <script type="text/javascript" src="../js/17.0.1/prop-types.js"></script>
  <script type="text/babel">
    class Person extends React.Component{
        state = {
            persons:[
                {id:1,name:'wtt',age:18},
                {id:2,name:'typ',age:19}
            ]
        }
        add=()=>{
            const {persons} = this.state
            const p = {id:3,name:'小王',age:20}
            this.setState({persons:[p,...persons]})
        }
        render(){
            return(
                <div>
                    <h2>展示人员信息</h2>
                    <button onClick={this.add}>添加一个小王</button>
                    <ul>
                        {
                            this.state.persons.map((p,index)=>{
                                return <li key={p.id}>{p.name}'---'{p.age} <input type="text"/> </li>
                            })
                        }
                    </ul>
                </div>
            )
        }
    }
    ReactDOM.render(<Person/>,document.getElementById('test'))
</script>
</body>

</html>